﻿using Cty.BLL.Dto.UserDto;
using Cty.BLL.Manager;
using Cty.Helper;
using HZY.Framework.DependencyInjection;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Cty.SprayingSCADA
{
    public partial class FormLogin : UILoginForm, ISingletonSelfDependency
    {
        private readonly UserManager _userManager;
        public FormLogin(UserManager userManager)
        {
            InitializeComponent();
            this._userManager = userManager;
        }

        private async void FormLogin_ButtonLoginClick(object sender, EventArgs e)
        {
            var res = await _userManager.LoginAsync(new UserLoginDto() { UserName = UserName, UserPassword = Password });

            if (res.Status == SystemEnums.Result.Success)
            {
                IsLogin = true;
                this.ShowSuccessTip("登录成功");
                Close();
            }
            else
            {
                this.ShowErrorTip(res.Msg);
            }
        }
    }
}
